﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Drawing;
using System.Linq;
using System.Web;

namespace EMRI.EmergencyCare.Web.Models
{
    public class Patient
    {
        [Key]
        public int PatientId { get; set; }

        [Display(Name = "Patient Name")]
        [MaxLength(250)]
        public string Name { get; set; }

        [Display(Name = "Critical")]
        public bool IsCritical { get; set; }

        [Display(Name = "Type Of Emergency")]
        [MaxLength(150)]
        public string TypeOfEmergency { get; set; }

        [Display(Name = "Referred")]
        public bool IsReferred { get; set; }
        public string HospitalName { get; set; }

        [Display(Name = "Duty Doctor")]
        public string Doctor { get; set; }

        [Display(Name = "EM Room Location")]
        [MaxLength(50)]
        public string Location { get; set; }

        public DateTime CreatedDate { get; set; }
    }

    public class PatientDetails
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.None)]
        public int PatientId { get; set; }
        
        [Display(Name = "Care Before Room Arrival")]
        [MaxLength(50)]
        public string BeforeCare { get; set; }

        [Display(Name = "Brought By")]
        [MaxLength(50)]
        public string Vehicle { get; set; }

        [Display(Name = "Cause Of Emergency")]
        [MaxLength(150)]
        public string CauseOfEmergency { get; set; }

        [Display(Name = "Mechanism Of Injury")]
        [MaxLength(150)]
        public string MechanismOfInjury { get; set; }

        [Display(Name = "Incident Location")]
        [MaxLength(100)]
        public string IncidentLocation { get; set; }

        [Display(Name = "Anatomical Area Of Emergency")]
        [MaxLength(150)]
        public string Anatomical { get; set; }

        [Display(Name = "MCI")]
        [MaxLength(30)]
        public string MCI { get; set; }

        [Display(Name = "Age")]
        public short Age { get; set; }

        [Display(Name = "Sex")]
        public Gender Sex { get; set; }

        [Display(Name = "Contact No")]
        [MaxLength(10)]
        public string Contact { get; set; }

        [Display(Name = "District")]
        public int District { get; set; }

        [Display(Name = "Taluk")]
        public int Taluk { get; set; }

        [Display(Name = "City")]
        public int City { get; set; }

        [Display(Name = "Social Habits")]
        [MaxLength(30)]
        public string SocialHabits { get; set; }

        [Display(Name = "Chief Complaint")]
        [MaxLength(150)]
        public string ChiefComplaint { get; set; }

        [Display(Name = "MOI/NOI & Incident Narration")]
        [MaxLength(500)]
        public string IncidentNarration { get; set; }

        [Display(Name = "InTime(DD/MM/YYYY HH:MM)")]
        public DateTime PatientInDateTime { get; set; }

        [Display(Name = "Document City")]
        public bool DocumentCity { get; set; }

        [Display(Name = "Entered By")]
        [MaxLength(150)]
        public string EnteredBy { get; set; }

        [Display(Name = "CityName")]
        [MaxLength(30)]
        public string TypedCityName { get; set; }

        [Display(Name = "108 Case ID")]
        [MaxLength(10)]
        public string CaseID108 { get; set; }

        public int InitialAssesmentPatientId { get; set; }
        [ForeignKey("InitialAssesmentPatientId")]
        public InitialAssesment InitialAssesment { get; set; }

        public int DetailedAssesmentPatientId { get; set; }
        [ForeignKey("DetailedAssesmentPatientId")]
        public DetailedAssesment DetailedAssesment { get; set; }

        public int InvestigationPatientId { get; set; }
        [ForeignKey("InvestigationPatientId")]
        [Display(Name = "Investigations: Findings & Reports")]
        public Investigation Investigation { get; set; }

        public int TreatmentPatientId { get; set; }
        [ForeignKey("TreatmentPatientId")]
        public Treatment Treatment { get; set; }

        public int SynopsisPatientId { get; set; }
        [ForeignKey("SynopsisPatientId")]
        public Synopsis Synopsis { get; set; }

    }

    public class InitialAssesment
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.None)]
        public int PatientId { get; set; }

        [Display(Name = "IsAlert")]
        public bool IsAlert { get; set; }

        [Display(Name = "IsVerbal")]
        public bool IsVerbal { get; set; }

        [Display(Name = "IsPain")]
        public bool IsPain { get; set; }

        [Display(Name = "IsUnresponsive")]
        public bool IsUnresponsive { get; set; }

        [Display(Name = "Intervention")]
        public string Locintervention { get; set; }

        [Display(Name = "Patent")]
        public bool HasPatentAirway { get; set; }

        [Display(Name = "Abnormal Sounds")]
        public bool IsAbnormalSoundsAirway { get; set; }

        [Display(Name = "Fluids")]
        public bool IsFluidsAirway { get; set; }

        [Display(Name = "Intervention")]
        public string AirwayIntervention { get; set; }

        [Display(Name = "Present")]
        public bool HasBreathing { get; set; }

        [Display(Name = "Rate")]
        public bool IsBreathingRateNormal { get; set; }

        [Display(Name = "Adequate")]
        public bool IsBreathingAdequate { get; set; }

        [Display(Name = "Intervention")]
        public string BreathingIntervention { get; set; }

        [Display(Name = "Present")]
        public bool Circulation { get; set; }

        [Display(Name = "Rate")]
        public bool CirculationRateNormal { get; set; }

        [Display(Name = "Regular")]
        public bool CirculationRegular { get; set; }

        [Display(Name = "Intervention")]
        public string CirculationIntervention { get; set; }

    }

    public class DetailedAssesment
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.None)]
        public int PatientId { get; set; }

        [Display(Name = "Head/Face")]
        public bool IsHead { get; set; }
        [Display(Name = "Neck")]
        public bool IsNeck { get; set; }
        [Display(Name = "Chest")]
        public bool IsChest { get; set; }
        [Display(Name = "Lungs")]
        public bool IsLungs { get; set; }
        [Display(Name = "Abdomen")]
        public bool IsAbdomen { get; set; }
        [Display(Name = "Pelvis")]
        public bool IsPelvis { get; set; }
        [Display(Name = "Extemities")]
        public bool IsExtemities { get; set; }
        [Display(Name = "Back")]
        public bool IsBack { get; set; }
        [Display(Name = "Nervous")]
        public bool IsNeuro { get; set; }
        public string HeadDesc { get; set; }
        public string NeckDesc { get; set; }
        public string ChestDesc { get; set; }
        public string LungsDesc { get; set; }
        public string AbdomenDesc { get; set; }
        public string PelvisDesc { get; set; }
        public string ExtemitiesDesc { get; set; }
        public string BackDesc { get; set; }
        public string NeuroDesc { get; set; }

        [Display(Name = "Signs")]
        public string HistorySigns { get; set; }
        [Display(Name = "Symptoms")]
        public string HistorySymptoms { get; set; }
        [Display(Name = "O / P / Q")]
        public string HistoryOpq { get; set; }
        [Display(Name = "R / S / T")]
        public string HistoryRst { get; set; }
        [Display(Name = "Allergies")]
        public string HistoryAllergies { get; set; }
        [Display(Name = "Medications")]
        public string HistoryMedications { get; set; }
        [Display(Name = "Past Illness")]
        public string HistoryPastIllness { get; set; }
        [Display(Name = "Events")]
        public string HistoryEvents { get; set; }
        [Display(Name = "Last Oral Intake")]
        public string HistoryLastOralIntake { get; set; }

        [ForeignKey("PatientId")]
        public List<Reading> Readings { get; set; }
    }

    public class Reading
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public int ID { get; set; }
        public int PatientId { get; set; }
        public DetailedAssesment DetailedAssesment { get; set; }

        [Display(Name = "Time (hh:mm)")]
        public string Time { get; set; }
        [Display(Name = "Pulse (Min)")]
        public string Pulse { get; set; }
        [Display(Name = "Resp (Min)")]
        public string Respirations { get; set; }
        [Display(Name = "BloodPressure (mmHg)")]
        public string BloodPressure { get; set; }
        [Display(Name = "Spo2 (%)")]
        public string Spo2 { get; set; }
        [Display(Name = "Pupils-R")]
        public string PupilsR { get; set; }
        [Display(Name = "Pupils-L")]
        public string PupilsL { get; set; }
        [Display(Name = "Cap.Refill")]
        public string Caprefill { get; set; }
        [Display(Name = "GRBS (mg/dl)")]
        public string Grbs { get; set; }
        [Display(Name = "Temp (F)")]
        public string Temp { get; set; }
        [Display(Name = "GCS")]
        public string Gcs { get; set; }
    }

    public class Investigation
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.None)]
        public int PatientId { get; set; }

        [Display(Name = "ECG")]
        public string Ecg { get; set; }

        [Display(Name = "X-Ray")]
        public string Xray { get; set; }

        //[Display(Name = "ECG")]
       // public byte[] Ecg { get; set; }

       // [Display(Name = "X-Ray")]
       // public byte[] Xray { get; set; }

        [Display(Name = "108 PCR")]
        public byte[] PCR { get; set; }

        [Display(Name = "PHOTO 1")]
        public byte[] Photos1 { get; set; }

        [Display(Name = "PHOTO 2")]
        public byte[] Photos2 { get; set; }

        public string Blood { get; set; }

        public string Others { get; set; }

      //  public byte[] Blood { get; set; }

       // public byte[] Others { get; set; }

        [Display(Name = "Telemtry")]
        public bool IsTelemtry { get; set; }

        public bool Pregnancy { get; set; }

        public bool G { get; set; }

        public bool P { get; set; }

        public bool L { get; set; }

        public bool D { get; set; }

        public bool A { get; set; }
    }

    public class Treatment
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.None)]
        public int PatientId { get; set; }

        [Display(Name = "Life Lines")]
        public List<LifeLine> LifeLines { get; set; }

        [Display(Name = "Face Mask")]
        public bool O2Facemask { get; set; }
        [Display(Name = "NRBM")]
        public bool O2Nrbm { get; set; }
        [Display(Name = "Nasal Cannula")]
        public bool O2NasalCannula { get; set; }
        [Display(Name = "Others")]
        public bool O2Others { get; set; }
        [Display(Name = "Time")]
        public string O2Time { get; set; }
        [Display(Name = "LPM")]
        public string O2Lpm { get; set; }

        [Display(Name = "Mechanical Ventilator")]
        public bool VentilatorMechanical { get; set; }
        [Display(Name = "Bag Mask")]
        public bool VentilatorBagMask { get; set; }
        [Display(Name = "Others")]
        public bool VentilatorOthers { get; set; }
        [Display(Name = "Mode")]
        public string VentilatorMode { get; set; }
        [Display(Name = "Rate")]
        public string VentilatorRate { get; set; }

        public List<TreatmentDetail> TreatmentDetails { get; set; }

        [Display(Name = "Suction")]
        public bool Suction { get; set; }
        [Display(Name = "OPA / NPA")]
        public bool OpaNpa { get; set; }
        [Display(Name = "ET / NT")]
        public bool EtNt { get; set; }
        [Display(Name = "Others")]
        public bool AirwayMgmtOthers { get; set; }

        public string SuctionSize { get; set; }
        public string OpaNpaSize { get; set; }
        public string EtNtSize { get; set; }
        public string AirwayMgmtOthersSize { get; set; }

        public bool SuctionSuccess { get; set; }
        public bool OpaNpaSuccess { get; set; }
        public bool EtNtSuccess { get; set; }
        public bool AirwayMgmtOthersSuccess { get; set; }

        public string SuctionTime { get; set; }
        public string OpaNpaTime { get; set; }
        public string EtNtTime { get; set; }
        public string AirwayMgmtOthersTime { get; set; }

        public string SuctionAttempt { get; set; }
        public string OpaNpaAttempt { get; set; }
        public string EtNtAttempt { get; set; }
        public string AirwayMgmtOthersAttempt { get; set; }

        [Display(Name = "Wound Care")]
        public bool Woundcare { get; set; }
        [Display(Name = "Suturing")]
        public bool Suturing { get; set; }
        [Display(Name = "Splinting")]
        public bool Splinting { get; set; }
        [Display(Name = "SMRD")]
        public bool Smrd { get; set; }
        [Display(Name = "Bleding Control")]
        public bool BleedingControl { get; set; }
        [Display(Name = "C-Collar")]
        public bool Ccollar { get; set; }
        [Display(Name = "AED")]
        public bool Aed { get; set; }
        [Display(Name = "CPR")]
        public bool Cpr { get; set; }
        public string CprDesc { get; set; }

        [Display(Name = "Physician-Incharge Advice")]
        public string Advice { get; set; }
        [Display(Name = "Summary")]
        public string Summary { get; set; }
    }

    public class TreatmentDetail
    {
        public TreatmentDetail()
        {
        }

        public TreatmentDetail(int patientId)
        {
            PatientId = patientId;
        }

        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public int ID { get; set; }
        public int PatientId { get; set; }
        public Treatment Treatment { get; set; }

        [Display(Name = "Time")]
        public string Time { get; set; }
        [Display(Name = "Interventions & Medication")]
        public string Interventions { get; set; }
        [Display(Name = "Details/Response")]
        public string Response { get; set; }
    }

    public class LifeLine
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public int ID { get; set; }
        public int PatientId { get; set; }
        public Treatment Treatment { get; set; }

        [Display(Name = "IV  IO")]
        public string Ivio { get; set; }
        [Display(Name = "Site")]
        public string Site { get; set; }
        [Display(Name = "#Attempt")]
        public string Attempt { get; set; }
        [Display(Name = "Success")]
        public bool Success { get; set; }
    }

    public class Synopsis
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.None)]
        public int PatientId { get; set; }

        [Display(Name = "Improved")]
        public bool HasImproved { get; set; }
        [Display(Name = "Status Quo")]
        public bool IsStatusQuo { get; set; }
        [Display(Name = "Deterioated")]
        public bool IsDeterioated { get; set; }
        [Display(Name = "Death")]
        public bool IsDeath { get; set; }
        [Display(Name = "Discharged")]
        public bool IsDischarged { get; set; }
        [Display(Name = "Admitted")]
        public bool IsAdmitted { get; set; }
        [Display(Name = "Medical & Disposables attached to patient")]
        public string MedicalDisposables { get; set; }
        [Display(Name = "Attender Name & Contact Details")]
        public string Attender { get; set; }
        [Display(Name = "48 Hrs followup")]
        public bool IsAlive { get; set; }
        [Display(Name = "Discharge Time (DD/MM/YYYY HH:MM)")]
        public DateTime DischargeDateTime { get; set; }

        [Display(Name = "Paramedic Name")]
        public string Name { get; set; }
    }

    public enum Gender
    {
        Male,
        Female
    }
}